<?php

// @formatter:off
/**
 * @file logout.php
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: logout.php 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/services/users/logout.php $
 */
// @formatter:on

class WCServiceUsersLogout extends WCService {
	//
	// Class methods.
	public function __construct() {
		$this->_requiredPermissions["to"][] = WC_PERM_USER_LOGOUT;
	}
	//
	// Protected methods.
	protected function runPOST() {
		global $wcSession;

		if($wcSession->isLogged()) {
			if(!$wcSession->logout()) {
				$this->setError(WC_HTTPERROR_INTERNAL_SERVER_ERROR, "Session could not be closed");
			} else {
				$this->_count++;
			}
		} else {
			$this->setError(WC_HTTPERROR_BAD_REQUEST, "Session already closed");
		}
	}
}
